import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/common/xindong_all.dart';
import 'package:xindong/utils/xindong_text_util.dart';

class XinDongProfileSectionWidget extends StatelessWidget {
  final String title;
  final String? reward;
  final String? content;
  final String placeholder;
  final Function() onTap;

  const XinDongProfileSectionWidget({
    Key? key,
    required this.title,
    required this.content,
    required this.reward,
    required this.placeholder,
    required this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    const TextStyle textStyle = TextStyle(color: DZColors.titleColor, fontSize: 16, fontWeight: FontWeight.w600);
    const TextStyle rewardTextStyle = TextStyle(color: DZColors.mainColor, fontSize: 11, height: 1.2);
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: kCellHeight,
        color: DZColors.cellColor,
        padding: const EdgeInsets.only(left: 16, right: 10),
        margin: const EdgeInsets.only(bottom: 1),
        child: Row(
          children: [
            Text(title, style: textStyle),
            if (!TextUtil.isEmpty(reward))
              Container(
                height: 16,
                margin: const EdgeInsets.only(left: 8),
                padding: const EdgeInsets.only(left: 5, right: 5),
                decoration: BoxDecoration(color: DZColors.mainLightColor, borderRadius: BorderRadius.circular(3)),
                child: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Text(reward!, style: rewardTextStyle),
                  ],
                ),
              ),
            Expanded(
              child: Text(
                TextUtil.isEmpty(content) ? placeholder : content!,
                style: TextStyle(
                    color: TextUtil.isEmpty(content) ? DZColors.mainColor : DZColors.contentColor, fontSize: 16),
                textAlign: TextAlign.right,
              ),
            ),
            const SizedBox(width: 4),
            XinDongAll.instance.defaultIconNext,
          ],
        ),
      ),
    );
  }
}
